package com.easy;

/**
 * Created by Lxk on 2020/2/27.
 */
public class Solution268 {

    public int missingNumber(int[] nums) {
        int num = nums.length;
        int sum = (1 + num) * num / 2;
        for (int i = 0; i < nums.length; i++) {
            sum -= nums[i];
        }
        return sum;
    }

    public static void main(String[] args) {
        int[] arr = {3, 0, 1};
        Solution268 solution268 = new Solution268();
        System.out.println(solution268.missingNumber(arr));
    }

}
